package cn.kgc.spring.config;

import cn.kgc.spring.entity.Computer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * @author: mosin
 * @version: v1.0  2022/4/23
 */
@Configuration   // 将当前类做为配置类进行使用 实现完全注解开发
@ComponentScan("cn.kgc.spring")
public class BeanConfig {  //  spring-config01.xml  配置文件    bean
    @Bean
    @Scope("prototype")
    public Computer computer1(){

        Computer computer = new Computer();
        computer.setPrice(1000);
        computer.setType("huawei");
        return  computer;
    }

    @Bean
    public Computer computer2(){

        Computer computer = new Computer();
        computer.setPrice(2000);
        computer.setType("mi");

        return  computer;
    }

}

